/*
 * @Author: yanghaoqiang
 * @Date: 2019-07-30 11:25:11 
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2019-08-01 11:46:44
 */
import util from '../../utils/index'
import {
 userModel
} from '../../apis/index.js'
const app = getApp()
Component({
  properties: {
    width:{
      type:String,
      value:'700rpx'
    },
    height:{
      type:String,
      value:'160rpx'
    }
  },
  data: {
    list:[]
  },
  methods: {
    goUrl(e){
      let item = e.currentTarget.dataset.item
      util.navigateToMiniProgram({
        appId:item.link
      })
    }
  },
  lifetimes:{
    attached() {
      let ad_list =app.globalData.ad_list
      ad_list = ad_list?ad_list:[]
      if(!ad_list.length){
        userModel.getBannerList().then(res=>{
          app.globalData.ad_list = res
          this.setData({
            list:res
          })
        })
      }else{
        this.setData({
          list:ad_list
        })
      }
    }
  }
})
